From bd5dc4beaa9b4425f2074ca1f91cc9ecbcf76379 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Fri, 28 Jan 2022 11:54:19 +0100 Subject: [PATCH] tests: run testcases in strict mode Since /sbin/fw4 invokes ucode in strict mode, we should do the same in test cases. Signed-off-by: Jo-Philipp Wich --- run_tests.sh | 2 +- tests/lib/mocklib.uc | 10 ++++++++++ tests/lib/mocklib/uci.uc | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/run_tests.sh b/run_tests.sh index 2bdefbd..dcc6802 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -70,7 +70,7 @@ run_testcase() { local code=$7 local fail=0 - ucode ${uenv:+-e "$uenv"} -e '{ + ucode -S ${uenv:+-e "$uenv"} -e '{ "MOCK_SEARCH_PATH": [ "'"$dir"'/files", "./tests/mocks" diff --git a/tests/lib/mocklib.uc b/tests/lib/mocklib.uc index bcbb740..5441bfb 100644 --- a/tests/lib/mocklib.uc +++ b/tests/lib/mocklib.uc @@ -1,4 +1,14 @@ {% + /* strict mode compliance: ensure that global variabes are defined */ + if (!exists(global, 'REQUIRE_SEARCH_PATH')) + global.MOCK_SEARCH_PATH = null; + + if (!exists(global, 'MOCK_SEARCH_PATH')) + global.MOCK_SEARCH_PATH = null; + + if (!exists(global, 'TRACE_CALLS')) + global.TRACE_CALLS = null; + let _fs = require("fs"); /* Force reloading fs module on next require */ diff --git a/tests/lib/mocklib/uci.uc b/tests/lib/mocklib/uci.uc index 542eeb8..69d2561 100644 --- a/tests/lib/mocklib/uci.uc +++ b/tests/lib/mocklib/uci.uc @@ -23,6 +23,7 @@ let fixup_config = (config) => { let rv = {}; + let n_section = 0; for (let stype in config) { switch (type(config[stype])) { -- 2.30.2